<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html"><head>
    <meta charset="utf-8">
    <title>{include file="common/title"}</title>

    <meta name="description" content="Dashboard">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--Basic Styles-->
    <link href="__DATA__/admin/style/bootstrap.css" rel="stylesheet">
    <link href="__DATA__/admin/style/font-awesome.css" rel="stylesheet">
    <link href="__DATA__/admin/style/weather-icons.css" rel="stylesheet">

    <!--Beyond styles-->
    <link id="beyond-link" href="__DATA__/admin/style/beyond.css" rel="stylesheet" type="text/css">
    <link href="__DATA__/admin/style/demo.css" rel="stylesheet">
    <link href="__DATA__/admin/style/typicons.css" rel="stylesheet">
    <link href="__DATA__/admin/style/animate.css" rel="stylesheet">
</head>
<body>
<!-- 头部 -->
{include file="common/top"}
<!-- /头部 -->

<div class="main-container container-fluid">
    <div class="page-container">
        <!-- Page Sidebar -->
        {include file="common/left"}
        <!-- /Page Sidebar -->
        <!-- Page Content -->
        <div class="page-content">
            <!-- Page Breadcrumb -->
            <div class="page-breadcrumbs">
                <ul class="breadcrumb">
                    <li class="active">控制面板</li>
                </ul>
            </div>
            <!-- /Page Breadcrumb -->

            <!-- Page Body -->
            <!--正文-->
            <form action="{:url('business/menu/search')}" method="post">
            <div class="input-group col-md-3" style="margin-top:10px;margin-left: 20px;">
            <input type="text" class="form-control" name="search" placeholder="请输入菜品名称" />
            <span class="input-group-btn">
            <button class="btn btn-info btn-search">搜索</button>
            <!--<button class="btn btn-info btn-search" style="margin-left:3px">添加</button>-->
            </span>
            </div>
            </form>
            <div class="page-body">
                <button type="button" tooltip="添加菜品" class="btn btn-sm btn-azure btn-addon" onClick="javascript:window.location.href = '{:url('business/menu/create')}'"> <i class="fa fa-plus"></i> 添加菜品
                </button>
                <button  type="button"  data-toggle="modal" onclick="allGet()"  data-target="#myModalc32" class="btn btn-sm btn-success">批量上架</button>
                <button  type="button"  data-toggle="modal" onclick="downGet()"  data-target="#myModalc32" class="btn btn-sm btn-default">批量下架</button>
                <button  type="button"  data-toggle="modal" onclick="deleteGet()"  data-target="#myModalc32" class="btn btn-sm btn-danger">批量删除</button>
                <div class="row">
                    <div class="col-lg-12 col-sm-12 col-xs-12">
                        <div class="widget">
                            <div class="widget-body">
                                <div class="flip-scroll">
                                    <table class="table table-bordered table-hover">
                                        <thead class="">
                                        <tr>
                                            <th class="text-center"></th>
                                            <th class="text-center">序号</th>
                                            <th class="text-center">类型</th>
                                            <th class="text-center">商品名称</th>
                                            <th class="text-center">分类</th>
                                            <th class="text-center">店内价格</th>
                                            <th class="text-center">外卖价格</th>
                                            <th class="text-center">餐盒费</th>
                                            <th class="text-center">库存</th>
                                            <th class="text-center">总销量</th>
                                            <th class="text-center">是否上架</th>
                                            <th class="text-center">操作</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        {volist name="data" id="v"}
                                        <tr>
                                            <td align="center">选择:<label><input   name="form-field-checkbox" type="checkbox" class="chanceId" value="{$v.id}" /><input name="form-field-checkbox" type="hidden" value="false" /><span class="text"></span></label></td>
                                            <td align="center">{$v.menu_order}</td>
                                            <td align="center"><span class="label label-warning">{$v.menu_type}</span></td>
                                            <td align="center">{$v.menu_name}</td>
                                            <td align="center">{$v.menu_classify}</td>
                                            <td align="center">{$v.menu_shop_price}</td>
                                            <td align="center">{$v.menu_side_price}</td>
                                            <td align="center">{$v.menu_box_price}</td>
                                            <td align="center">{$v.menu_stock}</td>
                                            <td align="center">{$v.menu_total}</td>
                                            {if condition="$v['menu_status'] eq 1 "}
                                            <td align="center"><button  type="button"  data-toggle="modal" onclick="ChangeStatus({$v.id})" data-target="#myModalc32" class="btn btn-sm btn-warning">点击下架</button></td>
                                            {else /}
                                            <td align="center"><button  type="button"  data-toggle="modal" onclick="ChangeStatus({$v.id})" data-target="#myModalc32" class="btn btn-sm btn-info">点击上架</button></td>
                                            {/if}
                                            <td align="center">
                                                <a href="{:url('business/menu/edit',array('id' => $v.id))}" class="btn btn-primary btn-sm shiny">
                                                    <i class="fa fa-edit"></i> 编辑
                                                </a>
                                                <a href="{:url('business/format/index',array('id' => $v.id))}" class="btn btn-info btn-sm shiny">
                                                    <i class="fa fa-edit"></i> 添加规格
                                                </a>
                                                <a href="{:url('business/menu/delete',array('id' => $v.id))}" class="btn btn-success btn-sm shiny">
                                                    <i class="fa fa-edit"></i> 删除
                                                </a>
                                            </td>
                                        </tr>
                                        {/volist}
                                        <!-- Modal -->
                                        </tbody>
                                    </table>
                                </div>
                                <div style="text-align:right; margin-top:10px;">
                                    {$data->render()}
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <script>
                function ChangeStatus($id) {
                    $.ajax({
                            type:"post",
                            url: "{:url('business/menu/changeStatus')}",
                            data: {'id':$id},
                            success:function(data){
                                if(data){
                                    history.go();
                                }else{
                                    layer.msg('修改失败', {icon: 5});
                                }
                            }
                        }
                    )
                }
                function allGet() {
                    var set = [];
                    $('.chanceId').each(function () {
                        var data = $(this).prop("checked");
                        if (data) {
                            var myId = $(this).attr("value");
                            set.push(myId);
                        }
                    });
//                    批量上架
                    $.ajax({
                            type:"post",
                            url: "{:url('business/menu/allChangeStatus')}",
                            data: {'arr':set},
                            success:function(data){
                                if(data){
                                    history.go();
                                }else{
                                    layer.msg('修改失败', {icon: 5});
                                }
                            }
                        }
                    )
                }
                function downGet() {
                    var set = [];
                    $('.chanceId').each(function () {
                        var data = $(this).prop("checked");
                        if (data) {
                            var myId = $(this).attr("value");
                            set.push(myId);
                        }
                    });
//                    批量上架
                    $.ajax({
                            type:"post",
                            url: "{:url('business/menu/downChangeStatus')}",
                            data: {'arr':set},
                            success:function(data){
                                if(data){
                                    history.go();
                                }else{
                                    layer.msg('修改失败', {icon: 5});
                                }
                            }
                        }
                    )
                }
                function deleteGet() {
                    var set = [];
                    $('.chanceId').each(function () {
                        var data = $(this).prop("checked");
                        if (data) {
                            var myId = $(this).attr("value");
                            set.push(myId);
                        }
                    });
//                    批量上架
                    $.ajax({
                            type:"post",
                            url: "{:url('business/menu/deleteChange')}",
                            data: {'arr':set},
                            success:function(data){
                                if(data){
                                    history.go();
                                }else{
                                    layer.msg('修改失败', {icon: 5});
                                }
                            }
                        }
                    )
                }


            </script>
            <!--Basic Scripts-->
            <script src="__DATA__/admin/style/jquery_002.js"></script>
            <script src="__DATA__/admin/style/bootstrap.js"></script>
            <script src="__DATA__/admin/style/jquery.js"></script>
            <!--Beyond Scripts-->
            <script src="__DATA__/admin/style/beyond.js"></script>
            <script>
                $(function(){
                    $('.caiping').css('display','block');
                });
            </script>


</body></html>